/**
 * Belongs to WEF
 */

var fartherHiddenIdValue;
var TableUtils = {
	/**
	 *config:{tableId,editFormId,beforeSave:function(obj,form){must return true or false},afterSave:function(obj,form)...
	 *  
	 *beforeLoadRow:function(){当想动态定义编辑表单的显示时刻，比如加载前才弹出编辑表单，此事件就有用。其他动态功能类似}
	 *processDWRService,loadMethodName,saveMethodName,saveButtonId,
	 *  objIdProperty }
	 *
	 */
	// @editor Guoxl 2009-04-28 9:46 add afterLoadRow property for config
	bindECTableWithDwrForm_ONE : function(config) {
		var table = TableUtils._getDomObjById(config.tableId);
		table.currentRow = null;
		table.currentRowBakConfig = {};
		var rows = $("#" + config.tableId + " tr.odd," + "#" + config.tableId
				+ " tr.even");
		rows.each(function(index, domObj) {
			//hansc 增加了if判断
			if(domObj != null || domObj != ''){
				//var clkHandler = $(domObj).attr("onclick");
				var clkHandler = null;
				var args = {};
				args.beforeLoadRow = config.beforeLoadRow;
				args.afterLoadRow = config.afterLoadRow;
				args.processDWRService = config.processDWRService
				args.loadMethodName = config.loadMethodName;
				args.editFormId = config.editFormId;
				args.ownHandler = clkHandler;
				args.table = table;
				args.row = domObj;
			args.saveButtonId = config.saveButtonId;
			args.cancelButtonId = config.cancelButtonId;
			args.addButtonId = config.addButtonId;
			args.copyButtonId = config.copyButtonId;
			$(domObj).bind("click", args, TableUtils._editRow);
			}
		});
		if (config.saveButtonId) {
			var saveBtn = $("#" + config.saveButtonId);
			saveBtn.bind("click", config, TableUtils._saveRow);
			isBindedSaveBtn = true;
		}
		if (config.addButtonId) {
			var addButton = $("#" + config.addButtonId);
			addButton.bind("click", config, TableUtils._addRow);
		}
		if (config.cancelButtonId) {
			var cancelBtn = $("#" + config.cancelButtonId);
			cancelBtn.bind("click", config, TableUtils._cancelRow);
		}
		if(config.copyButtonId){
			config.copyHandler=true;
			var copyBtn = $("#" + config.copyButtonId);
			copyBtn.bind("click", config, TableUtils._copyRow);
		}
	},
	/**
	 **config:{tableId,editFormId,dwrInterface,loadMethodName,saveActionUrl,saveButtonId}
	 */
	bindECTableEditableWithAjaxForm : function(config) {
		var table = TableUtils._getDomObjById(config.tableId);
		table.currentRow = null;
		table.currentRowBakConfig = {};
		var rows = $("#" + config.tableId + " tr.odd," + "#" + config.tableId
				+ " tr.even");
		rows.each(function(index, domObj) {
			//ECTABLE ROW没有ID属性，暂时使用onclick事件来辅助设置id
			//var clkHandler = $(domObj).attr("onclick");
			var clkHandler = null;
			$(domObj).bind("click", {
				table : table,
				row : domObj,
				beforeLoadRow : config.beforeLoadRow,
				dwr : {
					service : config.dwrInterface,
					method : config.loadMethodName
				},
				formId : config.editFormId,
				ownHandler : clkHandler
			}, TableUtils._editRow);
		});
		if (config.saveButtonId) {
			var saveBtn = $("#" + config.saveButtonId);
			saveBtn.bind("click", {
				dwr : {
					service : config.dwrInterface,
					method : config.saveMethodName
				},
				beforeSave : config.beforeSave,
				afterSave : config.afterSave,
				formId : config.editFormId,
				idProperty : config.objIdProperty
			}, TableUtils._saveRow);
		}
	},
	// @added by guoxl 20090427，取消按钮的事件处理
	// @updated by Liuzg 20090723, 控制按钮可用权限
	_cancelRow : function(event) {
		TB_showMaskLayer();
		var context = event.data;
		var table = TableUtils._getDomObjById(context.tableId);
		if(table.currentRow == undefined || table.currentRow == null){
			FormUtils.clearForm(context.editFormId);
			$('#'+context.editFormId+'Div').css('display','none');
			$('#'+context.cancelButtonId).attr('disabled',true);
			$('#'+context.saveButtonId).attr('disabled',true);
			TB_removeMaskLayer();
			return false;
		}
		if (table.currentRow.id == "" || table.currentRow.id == undefined
				|| table.currentRow.id == null) {
			alert(" can not find the row id ");
			return false;
		}
		if (context.ownHandler) {
			context.ownHandler();
		}

		if (context.beforeLoadRow) {
			context.beforeLoadRow(table.currentRow.id);
		}
		context.processDWRService[context.loadMethodName](table.currentRow.id, {
			callback : function(obj) {
				FormUtils.convertSimpleObject2Form(obj, context.editFormId);
				TableUtils._getDomObjById(context.editFormId).data = obj;
				TB_removeMaskLayer();
			},
			errorHandler : function(errorString, exception) {
				alert(errorString + ": " + exception);
				TB_removeMaskLayer();
			}
		});		
	},
	_saveRow : function(event) {
		TB_showMaskLayer();
		var context = event.data;

		var obj = FormUtils.convertSimpleForm2Object(context.editFormId,
				TableUtils._getDomObjById(context.editFormId).data);
		if (obj[context.objIdName] != "" && obj[context.objIdName] != null
				&& obj[context.objIdName] != undefined) {
			//modified status
			obj.rowStatus = 16;
		} else {
			//new add status
			obj.rowStatus = 4;
		}
		if (context.beforeSave) {
			if (!context.beforeSave(obj, TableUtils._getDomObjById(context.editFormId))) {
				TB_removeMaskLayer();
				return false;
			}
		}
		
		if(context.editFormId){
			if($('#'+context.editFormId + 'Div')){
				$('#'+context.editFormId + 'Div').css('display','none');
			}
		}
		if(context.saveButtonId){
			if($('#'+context.saveButtonId)){
				$('#'+context.saveButtonId).attr('disabled',true);
			}
		}
		if(context.cancelButtonId){
			if($('#'+context.cancelButtonId)){
				$('#'+context.cancelButtonId).attr('disabled',true);
			}
		}
		if(context.copyButtonId){
			if($('#'+context.copyButtonId)){
				$('#'+context.copyButtonId).attr('disabled',true);
			}
		}
		context.processDWRService[context.saveMethodName](obj, {
			callback : function(obj) {
				var idField = $("#" + context.editFormId + " :input[name='"
						+ context.objIdName + "']");
				if (idField) {
					$(idField).val(obj[context.objIdName]);
				}
				if (context.afterSave) {
					context.afterSave(obj, TableUtils
							._getDomObjById(context.editFormId));
				}
				//delete window.parent.IS_DIRTY_FUNC[window.parent.ACTIVE_TAB_ID];
				//if(inputsDatacheckedForm)
					//inputsDatacheckedForm[context.editFormId] = null;
				TB_removeMaskLayer();
				initFileds(context.editFormId);//重新初始化表单输入域
			},
			errorHandler : function(errorString, exception) {
				alert(errorString);
				TB_removeMaskLayer();
			}
		});
	},
	// @added by Liuzg 20090723，新增按钮的事件处理
	_addRow : function(event){
		var context = event.data;
		if($('#'+context.saveButtonId)){
			$('#'+context.saveButtonId).removeAttr('disabled');
		}
		if($('#'+context.cancelButtonId)){
			$('#'+context.cancelButtonId).removeAttr('disabled');
		}
		$('#'+context.editFormId+'Div').css('display','block');
		FormUtils.clearForm(context.editFormId);
	},	
	///////////////////////////////////////////////////////////////////////////////////

	/**
	 * *config:{tableId,editFormId,dwrInterface,loadMethodName,saveActionUrl,saveButtonId}
	 */
	bindECTableDWRForm_MANY : function(config) {
		var table = TableUtils._getDomObjById(config.tableId);
		table.currentRow = null;
		table.currentRowBakConfig = {};
		var rows = $("#" + config.tableId + " tr.odd," + "#" + config.tableId
				+ " tr.even");
		rows.each(function(index, domObj) {
			//var clkHandler = $(domObj).attr("onclick");
			var clkHandler = null;
			var args = {};
			args.beforeLoadRow = config.beforeLoadRow;
			args.processDWRService = config.processDWRService
			args.loadMethodName = config.loadMethodName;
			args.editFormId = config.editFormId;
			args.ownHandler = clkHandler;
			args.table = table;
			args.row = domObj;
			args.saveButtonId = config.saveButtonId;
			args.cancelButtonId = config.cancelButtonId;
			$(domObj).bind("click", args, TableUtils._editRow);
		});
		if (config.saveButtonId) {
			var saveBtn = $("#" + config.saveButtonId);
			saveBtn.bind("click", config, TableUtils._saveRow_M);
		}
		if (config.newButtonId) {
			var newButton = $("#" + config.newButtonId);
			newButton.bind("click", config, TableUtils._addRow);
		}
		if (config.cancelButtonId) {
			var cancelBtn = $("#" + config.cancelButtonId);
			cancelBtn.bind("click", config, TableUtils._cancelRow);
		}
	},
	bindFatherDWR : function(config) {
		var fatherFormId = config.fatherFormId;
		var fatherIdName = config.fatherIdName;
		var url=window.location.search;
		
		var idValue = $("#" + config.fatherHiddenId).val();
		fartherHiddenIdValue = idValue;
		var saveBtn = $("#" + config.saveFatherButtonId);
		
		// Save Button
		saveBtn.bind("click", {
			dwr : {
				service : config.processDWRService,
				method : config.saveDWRServiceMethod
			},
			formId : fatherFormId,
			fatherHiddenId:config.fatherHiddenId,
			idProperty : fatherIdName,
			afterSave_js_fun : config.afterSave_js_fun,
			beforeSave_js_fun : config.beforeSave_js_fun
		}, TableUtils._saveFather);
		// Cancel Button
		if (config.cancelFatherButtonId) {
			var cancelBtn = $("#" + config.cancelFatherButtonId);
			cancelBtn.bind("click", {
				dwr : {
					service : config.processDWRService,
					method : config.loadDWRServiceMethod
				},
				formId : fatherFormId,
				idProperty : fatherIdName,
				idValue : idValue
			}, TableUtils._cancelFather);
		}
		// Load Record
		if (idValue == "" || idValue == undefined || idValue == null) {
			if(config.callbackOver)
				eval(config.callbackOver+'()');
		} else {
			TB_showMaskLayer();
			config.processDWRService[config.loadDWRServiceMethod](idValue,
					function(result) {
						if(config.afterLoadRow){
							config.afterLoadRow(result, config.editFormId);
						}				
						FormUtils.convertSimpleObject2Form(result, fatherFormId);
						TableUtils._getDomObjById(fatherFormId).data = result;
						if(config.afterLoadRow){
							config.afterLoadRow(result, config.fatherFormId);
						}
						if(config.callbackOver)
							eval(config.callbackOver+'()');
						TB_removeMaskLayer();
						if(url.indexOf('&isCopy=true')!=-1)
							$("#" + config.fatherHiddenId).val('');
					});
		}
	},
	_getDomObjById : function(id) {
		var jqueryObj = $("#" + id);
		var realDomObj = null;
		jqueryObj.each(function(index, domObj) {
			realDomObj = domObj;
			return false;
		});
		return realDomObj;
	},
	_saveFather : function(args) {
		TB_showMaskLayer();
		var context = args.data;
		var obj = FormUtils.convertSimpleForm2Object(context.formId, TableUtils
				._getDomObjById(context.formId).data);
		if (obj[context.idProperty] != "" && obj[context.idProperty] != null
				&& obj[context.idProperty] != undefined) {
			//modified status
			obj.rowStatus = 16;
		} else {
			//new add status
			obj.rowStatus = 4;
		}
		if (obj.sons != "" && obj.sons != null && obj.sons != undefined) {
			for (var i = 0; i < obj.sons.length; i++) {
				var mo = obj.sons[i];
				if (mo[context.idProperty] != ""
						&& mo[context.idProperty] != null
						&& mo[context.idProperty] != undefined) {
					mo.rowStatus = 16;
				} else {
					mo.rowStatus = 4;
				}
			}
		}
		
		//modified by shixy 20090518  给beforeSave_js_fun方法传入参数，方便页面进行调用
		if(context.beforeSave_js_fun){
			if (!context.beforeSave_js_fun(obj, TableUtils._getDomObjById(context.formId))) {
					TB_removeMaskLayer();
					return false;
			}
		}
		context.dwr.service[context.dwr.method](obj, {
			callback : function(obj) {
				var idField = $("#" + context.formId + " :input[name='"
						+ context.idProperty + "']");
				if (idField) {
					$(idField).val(obj[context.idProperty]);
				}
				$("#fatherId").val(obj.fatherId);

				if (context.afterSave_js_fun) {
					context.afterSave_js_fun();
				}
				TB_removeMaskLayer();
				//$("#" + context.fatherHiddenId).val(obj.IDValue);//新增以后将主键赋值给隐藏域，防止重复新增
			},
			errorHandler : function(errorString, exception) {
				alert(errorString);
				TB_removeMaskLayer();
			}
		});
	},
	_cancelFather : function(args) {
		TB_showMaskLayer();
		var context = args.data;
		var idValue = context.idValue;
		if (idValue == "" || idValue == undefined || idValue == null) {
			FormUtils.clearForm(context.formId);
			TB_removeMaskLayer();
		} else {
			// Load Record
			context.dwr.service[context.dwr.method](idValue,
					function(result) {
						FormUtils.convertSimpleObject2Form(result, context.formId);
						TableUtils._getDomObjById(context.formId).data = result;
						TB_removeMaskLayer();
					});
		}
	},
	_saveRow_M : function(args) {
		var context = args.data;
		//检查父亲Form是否已经保存，没保存，进行保存
		if (fartherHiddenIdValue == "" || fartherHiddenIdValue == null
				|| fartherHiddenIdValue == undefined) {
			var config = context.fatherConfig;
			var afterSave_js_fun_new = function() {
				config.afterSave_js_fun();
				TableUtils._saveRow_M1(args);
			}
			TableUtils._saveFather({
				data : {
					dwr : {
						service : config.processDWRService,
						method : config.saveDWRServiceMethod
					},
					formId : config.fatherFormId,
					idProperty : config.fatherIdName,
					afterSave_js_fun : afterSave_js_fun_new,
					beforeSave_js_fun : config.beforeSave_js_fun
				}
			});
		} else {
			TableUtils._saveRow_M1(args);
		}
	},
	_saveRow_M1 : function(args) {
		TB_showMaskLayer();
		var context = args.data;
		var fatherIdName = context.fatherConfig.fatherIdName;
		var obj = FormUtils.convertSimpleForm2Object(context.editFormId,
				TableUtils._getDomObjById(context.editFormId).data);
		if (obj[context.objIdName] != "" && obj[context.objIdName] != null
				&& obj[context.objIdName] != undefined) {
			//modified status
			obj.rowStatus = 16;
		} else {
			//new add status
			obj.rowStatus = 4;
			obj[fatherIdName] = fartherHiddenIdValue;//设置子表外键
		}
		if (context.beforeSave) {
			if (!context.beforeSave(obj, TableUtils._getDomObjById(context.editFormId))) {
				TB_removeMaskLayer();
				return false;
			}
		}
		
		if(context.editFormId){
			if($('#'+context.editFormId + 'Div')){
				$('#'+context.editFormId + 'Div').css('display','none');
			}
		}
		if(context.saveButtonId){
			if($('#'+context.saveButtonId)){
				$('#'+context.saveButtonId).attr('disabled',true);
			}
		}
		if(context.cancelButtonId){
			if($('#'+context.cancelButtonId)){
				$('#'+context.cancelButtonId).attr('disabled',true);
			}
		}
		
		context.processDWRService[context.saveMethodName](obj, {
			callback : function(obj) {
				var idField = $("#" + context.editFormId + " :input[name='"
						+ context.objIdName + "']");
				if (idField) {
					$(idField).val(obj[context.objIdName]);
				}
				if (context.afterSave) {
					context.afterSave(obj, TableUtils
							._getDomObjById(context.editFormId));
				}
				delete window.IS_DIRTY_FUNC[window.parent.ACTIVE_TAB_ID];
				inputsDatacheckedForm[context.editFormId] = null;
				textareasDatacheckedForm[context.editFormId] = null;
				selectsDatacheckedForm[context.editFormId] = null;
				initFileds(context.editFormId);//重新初始化表单输入域
				TB_removeMaskLayer();
			},
			errorHandler : function(errorString, exception) {
				alert(errorString);
				initFileds(context.editFormId);//重新初始化表单输入域
				TB_removeMaskLayer();			
			}
		});
	},
	_clickRow : function(event) {
		var context = event.data;
		
//		if (context.row.id == undefined || context.row.id == null
//				|| context.row.id == "") {
//			alert(" can not find the row id ");
//			return false;
//		}
		if (context.ownHandler) {
			context.ownHandler();
		}
//		if (context.row.id == "" || context.row.id == undefined
//				|| context.row.id == null) {
//			return ;
//		}
		if (context.row == context.table.currentRow) {
			return;
		}
		TableUtils._recoverCurrentRowConfig(context.table);
		TableUtils._backupRowConfig(context.table, context.row);
		context.row.onmouseover = null;
		context.row.onmouseout = null;
		context.row.className = "highlight";
		context.table.currentRow = context.row;
	},
	_copyRow:function(event){
		var context = event.data;
		if(context.copyHandler){
			document.getElementById(context.objIdName.substring(0,context.objIdName.length-2)+'HiddenId').value='';
			alert('复制成功，请保存！');
		}
	},
	_editRow : function(event) {
		var context = event.data;
		var table = TableUtils._getDomObjById(context.tableId);
		if (context.row.id == undefined || context.row.id == null
				|| context.row.id == "") {
			alert(" can not find the row id ");
			return false;
		}
		if(context.editFormId){
			if($('#'+context.editFormId + 'Div')){
				$('#'+context.editFormId + 'Div').css('display','block');
			}
		}
		if(context.saveButtonId){
			if($('#'+context.saveButtonId)){
				$('#'+context.saveButtonId).removeAttr('disabled');
			}
		}
		if(context.cancelButtonId){
			if($('#'+context.cancelButtonId)){
				$('#'+context.cancelButtonId).removeAttr('disabled');
			}
		}
		if(context.copyButtonId){
			if($('#'+context.copyButtonId)){
				$('#'+context.copyButtonId).removeAttr('disabled');
			}
		}
		if (context.row.id.substring(0,1)=='#') {
			TableUtils._recoverCurrentRowConfig(context.table);
			TableUtils._backupRowConfig(context.table, context.row);
			context.row.onmouseover = null;
			context.row.onmouseout = null;
			context.row.className = "highlight";
			context.table.currentRow = context.row;
			return false;
		}
		if (context.ownHandler) {
			context.ownHandler();
		}
		if (context.row.id == "" || context.row.id == undefined
				|| context.row.id == null) {
			return false;
		}
		
		if (context.row == context.table.currentRow) {
			return true;//防止两次点击不能选中checkbox， add by zhaoym 2009-10-20
		}
		try{
			if(inputsDatacheckedForm[context.editFormId]){
				if(checkModification(context.editFormId))
				{
					if(window.confirm('数据已修改，请点击保存按钮。')){
						return;
					}
				}
			}
		}catch(e){
			
		}
		TableUtils._recoverCurrentRowConfig(context.table);
		TableUtils._backupRowConfig(context.table, context.row);
		context.row.onmouseover = null;
		context.row.onmouseout = null;
		context.row.className = "highlight";
		context.table.currentRow = context.row;

		if (context.beforeLoadRow) {
			context.beforeLoadRow(context.row.id);
		}
		
		TB_showMaskLayer("Loading...");
		context.processDWRService[context.loadMethodName](context.row.id, {
			callback : function(obj) {
				FormUtils.convertSimpleObject2Form(obj, context.editFormId);
				if(context.afterLoadRow){
					context.afterLoadRow(obj, context.editFormId);
				}
				TableUtils._getDomObjById(context.editFormId).data = obj;
				initFileds(context.editFormId);
				
				// added by gxl 2009-08-24 18:54 Begin
				window.parent.IS_DIRTY_FUNC[window.parent.ACTIVE_TAB_ID] = function(){	
					if(!status){
						try{
							if( inputsDatacheckedForm[context.editFormId] && checkModification(context.editFormId)){
								return true;
							}
						}catch(e){}
						return false;
					}	
				};
				window.onbeforeunload = function(){	
					if(!status){
						try{
							if(inputsDatacheckedForm[context.editFormId] && checkModification(context.editFormId)){
								return '数据已修改，请点击保存按钮。';
							}
						}catch(e){}
					}	
				};
				// added by gxl 2009-08-24 18:54 End
				TB_removeMaskLayer();
			},
			errorHandler : function(errorString, exception) {
				alert(errorString + ": " + exception);
				TB_removeMaskLayer();
			}
		});		
	},
	_ajaxDiv : function(args) {
		TB_showMaskLayer();
		$.ajax({
			type : "POST",
			url : args.ajaxUrl,
			timeout : 20000,
			error : function() {
				alert('error');
			},
			data : args.ajaxParamData,
			success : function(msg) {
				var text = msg.split("<!--###-->");
				//当AJAX请求失败时添加一个被执行的方法
				$("#" + args.ajaxDivId).ajaxError(function(request, settings) {
					$(this).append("<li>Error requesting page " + settings.url
							+ "</li>");
				});
				//当AJAX请求成功时添加一个被执行的方法
				$("#" + args.ajaxDivId).html(text[1]);
				if(args.afterAjax_js_fn)
					args.afterAjax_js_fn();
				//当AJAX请求成功时添加一个被执行的方法
				/*
				$("#" + args.ajaxDivId)
						.ajaxSuccess(function(request, settings) {
							$(this).html(text[1]);
							args.afterAjax_js_fn();
						});
						*/

				return false;
			}
		});
		TB_removeMaskLayer();
	},
	_ajaxDivH : function(args) {
		$.ajax({
			type : "POST",
			url : args.ajaxUrl,
			global  : false,
			timeout : 20000,
			error : function() {
				alert('error');
			},
			data : args.ajaxParamData,
			success : function(msg) {
				//当AJAX请求成功时添加一个被执行的方法
				var text = msg.split("<!--###-->");
				$("#" + args.ajaxDivId).html(text[1]);
				if(args.afterAjax_js_fn){
					args.afterAjax_js_fn();
				}
				return false;
			}
		});

	},
	_bindECTableClick : function(config) {
		var tableId = config.tableId;
		var table = TableUtils._getDomObjById(tableId);
		table.currentRow = null;
		table.currentRowBakConfig = {};
		var rows = $("#" + tableId + " tr.odd," + "#" + tableId + " tr.even");
		rows.each(function(index, domObj) {
			//var clkHandler = $(domObj).attr("onclick");
			var clkHandler = null;
			$(domObj).bind("click",{
				table : table,
				row : domObj,
				ownHandler : clkHandler
			},TableUtils._clickRow);
		});
	},
	_bindECTableDoubleClick : function(config) {
		var tableId = config.tableId;
		var table = TableUtils._getDomObjById(tableId);
		var copyButtonId=config.copyButtonId;
		if(copyButtonId){
			domObj=table.currentRow;
			$("#"+copyButtonId).bind("click",{
				table : table,
				doubleClickUrl : config.doubleClickUrl,
				idName : config.idName
			},TableUtils._bindECTableCopyClick_FUN);
		}
		
		table.currentRow = null;
		table.currentRowBakConfig = {};
		var rows = $("#" + tableId + " tr.odd," + "#" + tableId + " tr.even");
		rows.each(function(index, domObj) {
			//var clkHandler = $(domObj).attr("onclick");
			var clkHandler = null;
			$(domObj).bind("dblclick", {
				table : table,
				row : domObj,
				ownHandler : clkHandler,
				doubleClickUrl : config.doubleClickUrl,
				idName : config.idName
			}, TableUtils._bindECTableDoubleClick_FUN);
			$(domObj).bind("click",{
				table : table,
				row : domObj,
				ownHandler : clkHandler
			},TableUtils._clickRow);
		});
		
	},
	_bindECTableCopyClick_FUN : function(event) {
		var context = event.data;
		//var table = TableUtils._getDomObjById(context.tableId);
		if(!context.table.row)
		{
			alert(" can not find the row id ");
			return false;
		}
		context.table=context.table;
		context.row=context.table.currentRow;
		if (context.row.id == undefined || context.row.id == null
				|| context.row.id == "") {
			alert(" can not find the row id ");
			return false;
		}
		if (context.ownHandler) {
			context.ownHandler();
		}
		window.location = context.doubleClickUrl + "&" + context.idName + "="
				+ context.row.id+"&isCopy=true";
	},
	_bindECTableDoubleClick_FUN : function(event) {
		var context = event.data;
		if (context.row.id == undefined || context.row.id == null
				|| context.row.id == "") {
			alert(" can not find the row id ");
			return false;
		}
		if (context.ownHandler) {
			context.ownHandler();
		}
		window.location = context.doubleClickUrl + "&" + context.idName + "="
				+ context.row.id;
	},
	//////////////////////////////////////////////////////////////////
	_recoverCurrentRowConfig : function(table) {
		var currentRow = table.currentRow;
		var currentRowBakConfig = table.currentRowBakConfig;
		if (currentRow) {
			currentRow.className = currentRowBakConfig.className;
			currentRow.onmouseover = currentRowBakConfig.onmouseover;
			currentRow.onmouseout = currentRowBakConfig.onmouseout;
			table.currentRow = null;
		}
	},
	_backupRowConfig : function(table, row) {
		if ((row.rowIndex-1 ) % 2 == 0) {
			table.currentRowBakConfig.className = "even";
		} else {
			table.currentRowBakConfig.className = "odd";
		}
		table.currentRowBakConfig.onmouseover = row.onmouseover;
		table.currentRowBakConfig.onmouseout = row.onmouseout;
	},
	_cancelBubble : function(event) {
		(event || window.event).cancelBubble = true;
	}
};